(defun c:flatxjoin()

;GET SNAPMODE

	(setq myosmode (getvar "osmode"))  


;SET NEAR SNAP

  	(setvar "osmode" 512)

  
;FLATTEN 3D POLYLINE

(command "MOVE" (getpoint "\nSelect 3D Polyline: ") "" "0,0,10e99" "0,0,10e99")


;Explode Polyline and join it back together  

	(command "explode" (getpoint "\nSelect Entitiy to Explode and Join: "))
	(command "pedit" "m" "P" "" "y" "j" "" "")


;Reset Snap Mode
  
	(setvar "osmode" myosmode)  

  


  
	
)